// pages/search/search.js
import {
  getSearchDefault,
  getSearchSuggest,
  getSearchHotDefault,
  getSearchMultiMatch
} from '../../api/index'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    placeholder: '',
    searchValue: '', //  搜索值
    hotList: [], //   热门搜索
    searchList: [], //  搜索结果
    historyList: [], //  历史记录
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getSearchDetail()
    const { placeholder, searchValue  } = this.data
    console.log(this.data, 'placeholder')
  },

  // 搜索 placeholderList
  async getSearchDetail(){
    const { searchValue } = this.data
    const { data } = await getSearchDefault()
    this.setData({
      placeholder: data.showKeyword,
      searchValue: searchValue || data.showKeyword
    })
  },

  async onSearchMusic(event) {
    const { searchValue } = this.data
    const { result } = await getSearchMultiMatch({ keywords: searchValue })
    console.log(result)

  }
})